﻿using Caliburn.Micro;
using PicturePortfolio.Silverlight.Extension;
using PicturePortfolio.Silverlight.Message;
namespace PicturePortfolio.Silverlight.ViewModels
{
    public class PopupContentViewModel:PropertyChangedBase,IChildWindow,IHandle<CloseMessage>
    {
        public PopupContentViewModel(object view)
        {
            this.PopupContent = view;
            EventAggregationProvider.EventAggregator.Subscribe(this);
        }

        private object _popupContent;
        public object PopupContent
        {
            get { return _popupContent; }
            private set
            {
                _popupContent = value;
                NotifyOfPropertyChange(() => PopupContent);
            }
        }

        CloseDelegate _closeDelegate;
        public CloseDelegate PopupCloseDelegate
        {
            get
            {
                return _closeDelegate;
            }
            set
            {
                _closeDelegate = value;
            }
        }
        public void ClosePreview()
        {
            this._closeDelegate();
        }

        public void Handle(CloseMessage message)
        {
            this._closeDelegate();
        }
    }
}
